package com.zzstm.eduservice.controller;


import com.zzstm.commonUtils.R;
import com.zzstm.eduservice.client.VodClient;
import com.zzstm.eduservice.entity.EduVideo;
import com.zzstm.eduservice.service.EduVideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 课程视频 前端控制器
 * </p>
 *
 * @author testjava
 * @since 2022-10-30
 */
@RestController
@RequestMapping("/eduservice/video")
@CrossOrigin
public class EduVideoController {

    @Autowired
    private EduVideoService videoService;


    //添加小节
    @PostMapping("/addVideo")
    public R addVideo(@RequestBody EduVideo video){
        videoService.save(video);
        return R.ok();
    }

    //删除小节
    @DeleteMapping("{videoId}")
    public R delete(@PathVariable String videoId){
        videoService.removeVideoById(videoId);
        return R.ok();
    }

    //根据id查询小节
    @GetMapping("/getVideoInfo/{videoId}")
    public R getVideoInfo(@PathVariable String videoId){
        EduVideo video = videoService.getById(videoId);
        return R.ok().data("video",video);
    }
    //修改小节
    @PostMapping("/updateVideo")
    public R updateVideo(@RequestBody EduVideo video){
        videoService.updateById(video);
        return R.ok();
    }

}

